﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Micro.Core.Options
{
    public class DbConfig
    {
        /// <summary>
        /// 主库名称
        /// </summary>
        public string MainDB { get; set; }

        /// <summary>
        /// 是否开启多库模式
        /// </summary>
        public bool MutiDBEnabled { get; set; } = false;

        /// <summary>
        /// //是否开启读写分离模式,必须是单库模式，且数据库类型一致，比如都是SqlServer
        /// </summary>
        public bool CQRSEnabled { get; set; } = false;

        public List<DbOption> DbOptions { get; set; } = new List<DbOption>();



        
    }
    /// <summary>
    /// {
    /// "ConnId": "WMBLOG_SQLITE",
    /// "DBType": 2,
    /// "Enabled": false,
    /// "HitRate": 50, // 值越大，优先级越高
    /// "Connection": "WMBlog.db" //sqlite
    /// }
    /// </summary>
    public class DbOption
    {
        /// <summary>
        /// 连接ID
        /// </summary>
        public string ConnId { get; set; }

        /// <summary>
        /// 数据库类型
        /// </summary>
        public DBType DBType { get; set; }

        /// <summary>
        /// 连接启用开关
        /// </summary>
        public bool Enabled { get; set; } = false;

        /// <summary>
        /// 从库执行级别，越大越先执行
        /// </summary>
        public int HitRate { get; set; }

        /// <summary>
        /// 数据连接
        /// </summary>
        public string Connection { get; set; }


    }

    /// <summary>
    /// 数据库类型
    /// </summary>
    public enum DBType
    {
        MySql = 0,
        SqlServer = 1,
        Sqlite = 2,
        Oracle = 3,
        PostgreSQL = 4,
        //Dm = 5,//达梦
        //Kdbndp = 6,//人大金仓
    }
}
